<?
include ('../../sessions.php');
include ('../../variables.php');
include('functions.php');
$webDIR="admin";
include("../session_check.php");


	if (getenv(REQUEST_METHOD) == "GET") {
		include('refGroups.html');
	} else if (getenv(REQUEST_METHOD) == "POST") {

		switch($action) {

			case "delRef":
				$ref = validate($HTTP_POST_VARS[ref]);
				$group = validate($HTTP_POST_VARS[group]);

                                        if(!$ref || !$group){
                                                $errorMsg = "ERROR - 1";
						include("refGroups.html");
                                                exit_now();
                                        }
					if(!del_referer($ref,$group)){
                                                $errorMsg = "ERROR - 2";
                                                include("refGroups.html");
                                                exit_now();
					}
                                $statusMsg="REFERE $ref deleted from group $group - OK";
                                include("refGroups.html");
                                exit_now();


			break;
                        case "addRef":
                                $ref = validate($HTTP_POST_VARS[ref]);
                                $group1 = validate($HTTP_POST_VARS[group1]);
				$group2 = validate($HTTP_POST_VARS[group2]);
				$n = validate($HTTP_POST_VARS[n]);
				
				if($n==1) $group=$group1;
				else $group=$group2;


                                        if(!$ref || !$group){
                                                $errorMsg = "ERROR - 1";
                                                include("refGroups.html");
                                                exit_now();
                                        }
                                        if(!add_referer($ref,$group)){
                                                $errorMsg = "ERROR - 2";
                                                include("refGroups.html");
                                                exit_now();
                                        }
                                $statusMsg="REFERER $ref added in group $group - OK";
                                include("refGroups.html");
                                exit_now();


                        break;
			default:
			break;
		}
	}
exit_now();
?>
